package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyGoldPoint;
import com.laowang.project.system.service.MyGoldPointService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 金币与积分Controller
 *
 * @author laowang
 * @date 2023-07-12
 */
@Api(tags = "金币与积分接口")
@RestController
@RequestMapping("/goldPoint")
public class MyGoldPointController extends BaseController {
    @Autowired
    private MyGoldPointService myGoldPointService;

    /**
     * 修改金币与积分
     */
    @ApiOperation(value = "小程序端  金币兑换积分",notes = "")
    @GetMapping("/web/list")
    public AjaxResult weblist() {
        List<MyGoldPoint> myGoldPoints = myGoldPointService.selectMyGoldPointList(null);
        return AjaxResult.success("操作成功",myGoldPoints);
    }


    /**
     * 查询金币与积分列表
     */
    @ApiOperation(value = "查询金币与积分列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:goldPoint:list')")
    @GetMapping("/list")
    public TableDataInfo list(MyGoldPoint myGoldPoint) {
        startPage();
        List<MyGoldPoint> list = myGoldPointService.selectMyGoldPointList(myGoldPoint);
        return getDataTable(list);
    }

    /**
     * 导出金币与积分列表
     */
    @ApiOperation(value = "导出金币与积分列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:goldPoint:export')")
    //@Log(title = "金币与积分", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyGoldPoint myGoldPoint) {
        List<MyGoldPoint> list = myGoldPointService.selectMyGoldPointList(myGoldPoint);
        ExcelUtil<MyGoldPoint> util = new ExcelUtil<MyGoldPoint>(MyGoldPoint.class);
        return util.exportExcel(list, "goldPoint");
    }

    /**
     * 获取金币与积分详细信息
     */
    @ApiOperation(value = "获取金币与积分详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:goldPoint:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myGoldPointService.selectMyGoldPointById(id));
    }

    /**
     * 新增金币与积分
     */
    @ApiOperation(value = "新增金币与积分",notes = "")
    @PreAuthorize("@ss.hasPermi('my:goldPoint:add')")
    //@Log(title = "金币与积分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyGoldPoint myGoldPoint) {
        return toAjax(myGoldPointService.insertMyGoldPoint(myGoldPoint));
    }

    /**
     * 修改金币与积分
     */
    @ApiOperation(value = "修改金币与积分",notes = "")
    @PreAuthorize("@ss.hasPermi('my:goldPoint:edit')")
    //@Log(title = "金币与积分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyGoldPoint myGoldPoint) {
        return toAjax(myGoldPointService.updateMyGoldPoint(myGoldPoint));
    }

    /**
     * 删除金币与积分
     */
    @ApiOperation(value = "删除金币与积分",notes = "")
    @PreAuthorize("@ss.hasPermi('my:goldPoint:remove')")
    @Log(title = "金币与积分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myGoldPointService.deleteMyGoldPointByIds(ids));
    }
}
